<?php
/*
# ------------------------------------------------------------------------
# JA Job Board Package
# ------------------------------------------------------------------------
# Copyright (C) 2004-2010 JoomlArt.com. All Rights Reserved.
# @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
# Author: JoomlArt.com
# Websites: http://www.joomlart.com - http://www.joomlancers.com.
# ------------------------------------------------------------------------
*/
defined('_JEXEC') or die('Restricted access'); 

$url	=	$mainframe->getSiteUrl()."/components/com_jl_project/assets/images/icons/profile/";

$editor =& JFactory::getEditor();

$row = $this->row;

JFilterOutput::objectHTMLSafe( $row, ENT_QUOTES, 'description' );
$cparams = JComponentHelper::getParams ('com_media');

?>
<script language="javascript" type="text/javascript">
function submitbutton(pressbutton) {
	var form = document.adminForm;
	if (pressbutton == 'cancel') {
		submitform( pressbutton );
		return;
	}
	if ((pressbutton == 'save')||(pressbutton == 'apply')) {
		if ( form.title.value == "" ) {
			alert("<?php echo JText::_( 'Posting plan must have title', true ); ?>");
			form.title.focus();
			return;
		}
		
		var cost =form.price.value;
		var posts_type = form.type.value;
		var numericExpression = /^[0-9]+$/;
		var numericExpression1 = /^[0-9]+\.[0-9]{1,2}$/;
		$submitform = 0;
		var posting_value = form.value.value;
		if ((posting_value == ""))
		{
			if (posts_type!='resume')
				alert("<?php echo JText::_( 'Posting quantity could not be empty', true ); ?>");
			else
				alert("<?php echo JText::_( 'Durations could not be empty', true ); ?>");
			
			form.value.focus();
			return;
		}
		else 
		{
			if(posting_value !="")
			{
				if(!isNaN(posting_value))
				{
					$submitform =1;
				}
				else
				{
					if (posts_type!='resume')
						alert("<?php echo JText::_( 'Posting quantity must be numeric', true ); ?>");
					else
						alert("<?php echo JText::_( 'Durations must be numeric', true ); ?>");
						
					form.value.focus()
					return;
				}
			}
			
		}
		
		if ((cost == ""))
		{
			alert("<?php echo JText::_( 'Price could not be empty', true ); ?>");
			form.price.focus();
			return;
		}
		else 
		{
			if(cost !="")
			{
				if(cost.match(numericExpression)||cost.match(numericExpression1))
				{
					$submitform =1;
				}
				else
				{
					alert("<?php echo JText::_( 'Price must be numeric', true ); ?>");
					form.price.focus();
					return;
				}
			}
			
		}
		
		if($submitform ==1)
		{
			submitform(pressbutton);
			return;
		}
	}
	else {
		<?php
		echo $editor->save( 'description' ) ; 
		?>
		submitform(pressbutton);
	}
}
function RemoveImage(filename,type,controller,id){
	$('showimg').innerHTML = "";
	$('remove_img').value = 1;
}
function Change_PlanType (type)
{
	var lbl_type = document.getElementById('lbl_type');
	var lbl_type_unit = document.getElementById('lbl_type_unit');
	if (type!='resume')
	{
		lbl_type.innerHTML = 'Posting Quantity:';
		lbl_type_unit.innerHTML = 'times';
	}
	else
	{
		lbl_type.innerHTML = 'Durations:';
		lbl_type_unit.innerHTML = 'days';
	}
}
</script>
		
<form name="adminForm" action="index.php" method="post" enctype="multipart/form-data">

	<table width="100%">
	<tr>
	
		<td width="80%" valign="top" align="left">
		
		    <div style="width:100%;">
				<fieldset class="adminform">
					<legend><?php echo JText::_( 'Subscription Details' ); ?></legend>
						<table class="admintable">
						<tr>
							<td class="key">
								<label for="title" width="100">
									<?php echo JText::_( 'Title' ); ?>:					
								</label>
								<br />
								<small>
									<?php echo JText::_('Will be displayed to user');?>
								</small>
							</td>
							<td colspan="2">
								<input class="text_area" type="text" name="title" id="title" value="<?php echo isset($row->title)?$row->title:''; ?>" size="50" maxlength="50" title="<?php echo JText::_( 'A long name to be displayed in headings' ); ?>" />								
								<font color="Red">*</font>
							</td>
						</tr>
					
						<tr>
							<td width="120" class="key">
								<?php echo JText::_( 'Published' ); ?>:						</td>
							<td>
								<?php
								if ($row->id)
									$published = $row->published;
								 else 	
								 	$published = 1;
								$lists['published'] = JHTML::_('select.booleanlist',  'published', 'class="inputbox"', $published );
								 echo $lists['published']; ?>						
							</td>
						</tr>
						<tr>
							<td width="120" class="key">
								<?php echo JText::_( 'Enable TAX' ); ?>:						</td>
							<td>
								<?php
								if ($row->id)
									$enable_tax = $row->enable_tax;
								 else 	
								 	$enable_tax = 1;
								$lists['enable_tax'] = JHTML::_('select.booleanlist',  'enable_tax', 'class="inputbox"', $enable_tax );
								echo $lists['enable_tax']; ?>						
							</td>
						</tr>
						<tr>
							<td class="key">
								<label for="type">
									<?php echo JText::_('Posting Plan Type' ); ?>
								</label>
							</td>
							<td>
								<?php
									
									$arr_plantype = JobBoardConstant::getPostingPlan_Type();
									$arr_value = array_keys($arr_plantype);
									$html = "<select id='type' name='type' onchange='Change_PlanType(this.value)'>";	
									$temp_type = '';
									$temp_value	 = '';
									if (isset($row->type))									
										$temp_type = $row->type;
									if (isset($row->value))									
										$temp_value = $row->value;
									foreach ($arr_value as $value)
										if ($temp_type!=$value)
											$html.="<option value='".$value."'>".$arr_plantype[$value]."</option>";
										else 
											$html.="<option selected='1' value='".$value."'>".$arr_plantype[$value]."</option>";
									$html.= "</select>";
									echo $html
								?>
							</td>
						</tr>						
						<tr>
							<td valign="top" class="key">
								<label id="lbl_type" for="access">
								
									<?php 
										if ($temp_type!='resume')
											echo JText::_( 'Posting Quantity' ); 
										else 
											echo JText::_('Durations');
									?>:	
								</label>							
							</td>
							<td>
								<input type="text" value="<?php echo $temp_value; ?>" name="value" id="value" size="5"/>	
								<label  id="lbl_type_unit">
									<?php 
										if ($temp_type!='resume')
											echo JText::_( 'Times' ); 
										else 
											echo JText::_('days');
								 	?>
								 </label>
								 <font color="Red">*</font>
								 <br/><br/>
								 <?php echo JText::_('With:  Posting plan type = Standard/Premium job, this is number of jobs can be posted by Employer after buying this plan<br/>With:  Posting plan type = Search Resume, this is number of days that Employer can search resume after buying this plan');?>
							</td>
						</tr>
						
						<tr>
							<td class="key">
								<label for="image">
									<?php echo JText::_( 'Price' ); ?>:	
								</label>
								<br/>
								<small><?php echo JText::_('Enter only digits (and period, if necessary).');?><small>
							</td>
							<td>
																	
									<input class="text_area" type="text" name="price" id="price" value="<?php echo isset($row->price)?$row->price:''; ?>"  size="10" maxlength="100"  /> <?php 
									if($this->config['currency']->get('mode', 'real_currency')=='real_currency'){
										echo $this->config['currency']->get('currency', '$');
									}
									else {
										echo $this->config['payment']->get('currency_symbol', 'credit');
									}
								?>
								<font color="Red">*</font>  
							</td>
						</tr>
						
						<tr>
							<td class="key">
								<label for="image_position">
									<?php echo JText::_( 'Description' ); ?>:
								</label>						
								<br/>
								<small><?php echo JText::_('Will be displayed to user on signup page below the title');?></small>
							</td>
							<td valign="top" colspan="3">
								<?php
								// parameters : areaname, content, width, height, cols, rows, show xtd buttons
								echo $editor->display( 'description',  htmlspecialchars(isset($row->description)?$row->description:'', ENT_QUOTES), '550', '200', '60', '20', array('pagebreak', 'readmore') ) ;
								?>
							</td>
						</tr>						
					</table>
				</fieldset>
				<br />

				
			</div>
		</td>
	</tr>
	</table>
	<div class="clr"></div>
	<!--<input type="hidden" name="image_old" value="<?php echo $old_image?>">-->
	<input type="hidden" name="option" value="<?php echo $this->option; ?>" />
	<input type="hidden" name="view" value="japostingplans" />
	<input type="hidden" name="oldtitle" value="<?php echo isset($row->title)?$row->title:'' ; ?>" />
	<input type="hidden" name="id" value="<?php echo $row->id; ?>" />
	<input type="hidden" name="cid" value="<?php echo $row->id; ?>" />
	<input type="hidden" name="task" value="" />
	<?php echo JHTML::_( 'form.token' ); ?>	
</form>
<style type="text/css">
	table.admintable td.key{
		width:250px;
	}								
</style>